filename='D:\\GITEE\\study_code\\Python\\2022-11-14\\alice.txt'

try:
    with open(filename,encoding='utf-8') as f:
        contents=f.read()
except FileNotFoundError:
    print(f"Sorry, the file {filename} does not exist .")
else:
    #计算该文件大致包含多少个单词
    words=contents.split()
    num_words=len(words)
    print(f"The file {filename} has about {num_words} words .")

#解释：split（）能根据一个字符串创建一个单词列表